grammar Qmanifest;

options
{
}

@parser::members
{
}

@lexer::members
{
}

/* Parser Rules */

compileUnit
	:	packageDirective importDirective* statement*
	;

packageDirective
	:	'package' package ';'
	;

importDirective
	:	'import' package ';'
	|	'import' Identifier 'as' fullComponentName ';'
	;
statement
	:	assemblyStatement
	;

assemblyStatement
	:	'assembly' assembly ';'
	;

package
	:	Identifier ('.' Identifier)*
	;

component
	:	fullComponentName
	|	componentName
	;

fullComponentName
	:	package '.' componentName
	;

componentName
	:	Identifier
	;

assembly
	:	assemblyName
	|	assemblyName ',' assemblyProperties
	;
assemblyName
	:	Identifier ('.' Identifier)*
	;
assemblyProperties
	:	AssemblyProperty (',' AssemblyProperty)*
	;


/* Lexer Rules */
Identifier
    :	Nondigit (Nondigit | Digit)*
    ;

Semi
	:	';'
	;

fragment
Alphabet
	:	[a-zA-Z]
	;
fragment
Nondigit
    :	[a-zA-Z_]
    ;
fragment
Digit
    :	[0-9]
    ;
fragment
HexaDigit
	:	[0-9A-Fa-f]
	;


AssemblyProperty
	:	'Version' '=' AssemblyVersion
	|	'PublicKey' '=' ('null' | AssemblyPublicKey)
	|	'PublicKeyToken' '=' ('null' | AssemblyPublicKeyToken)
	|	'Culture' '=' ('neutral' | LanguageTagOfRfc1766)
	|	'ProcessorArchitecture' '=' AssemblyProcessorArchitecture
	;
fragment
AssemblyPublicKey
	:	HexaDigit+
	;
fragment
AssemblyPublicKeyToken
	:	AssemblyPublicKeyTokenHexaDigit8 AssemblyPublicKeyTokenHexaDigit8
	;
fragment
AssemblyVersion
	:	AssemblyVersionComponent '.' AssemblyVersionComponent '.' AssemblyVersionComponent '.' AssemblyVersionComponent
	;
fragment
LanguageTagOfRfc1766
	:	LanguageSubTagOfRfc1766 '-' LanguageSubTagOfRfc1766
	;
fragment
AssemblyProcessorArchitecture
	:	('A'|'a')('M'|'m')('D'|'d')[6][4]
	|	('A'|'a')('R'|'r')('M'|'m')
	|	('I'|'i')('A'|'a')[6][4]
	|	('M'|'m')('S'|'s')('I'|'i')('L'|'l')
	|	('X'|'x')[8][6]
	;
fragment
AssemblyPublicKeyTokenHexaDigit8
	:	HexaDigit HexaDigit HexaDigit HexaDigit HexaDigit HexaDigit HexaDigit HexaDigit
	;
fragment
AssemblyVersionComponent
	:	[6] [5] [5] [3] [1-5]
	|	[6] [5] [5] [0-2] Digit
	|	[6] [5] [0-4] Digit Digit
	|	[6] [0-4] Digit Digit Digit
	|	[1-9] Digit Digit Digit Digit
	|	[1-9] Digit Digit Digit
	|	[1-9] Digit Digit
	|	[1-9] Digit
	|	Digit
	;
fragment
LanguageSubTagOfRfc1766
	:	Alphabet Alphabet Alphabet Alphabet Alphabet Alphabet Alphabet Alphabet
	|	Alphabet Alphabet Alphabet Alphabet Alphabet Alphabet Alphabet
	|	Alphabet Alphabet Alphabet Alphabet Alphabet Alphabet
	|	Alphabet Alphabet Alphabet Alphabet Alphabet
	|	Alphabet Alphabet Alphabet Alphabet
	|	Alphabet Alphabet Alphabet
	|	Alphabet Alphabet
	|	Alphabet
	;

WS	:	[ \t\v\r\n]+ -> skip;
